package com.kaibes.module.permission.api;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kaibes.module.permission.db.entity.Power;
import com.kaibes.module.permission.db.service.PowerService;
import com.kaibes.module.permission.pojo.PowerPost;
import com.kaibes.web.api.ApiLink;
import com.kaibes.web.api.ResponseApi;

@RestController
@RequestMapping("/powers")
public class PowerApi extends ResponseApi<Power, PowerService> { 
    
    @PostMapping
    @ApiLink("创建权限多个权限")
    public ResponseEntity<List<Number>> postList(@RequestBody @Validated List<PowerPost> powers) {
        return super.post(powers, "绑定权限成功", "绑定权限失败");
    }
    @PostMapping("/one")
    @ApiLink("创建权限单个")
    public ResponseEntity<List<Number>> post(@RequestBody @Validated PowerPost power) {
        return super.post(power, "绑定权限成功", "绑定权限失败");
    }
    
    @DeleteMapping
    @ApiLink("删除权限，根据id")
    public ResponseEntity<Object> delete(@RequestBody List<Integer> ids) {
        return super.deleteByIds(ids, "解绑权限成功", "解绑权限失败");
    }
    
}
